

set.seed(1000)


n <- 100
mean1 <- 0
sd1 <- 1
mean2 <- 2
sd2 <- 2


normal1 <- rnorm(n, mean=mean1, sd=sd1)
normal2 <- rnorm(n, mean=mean2, sd=sd2)

par(mfrow=c(1,2))

hist(normal1, breaks=30, col="blue", main="normal distribution (mean=0, std=1)", xlab="Value",
     ylab="Density", probability=TRUE)
curve(dnorm(x, mean=mean1, sd=sd1), add=TRUE, col='red', lwd=2)


hist(normal2, breaks=30, col="green", main="normal distribution(mean=2,std=2)", xlab="Value",
     ylab='Density', probability=TRUE)
curve(dnorm(x, mean=mean2, sd=sd2), add=TRUE, col='red', lwd=2)

par(mfrow=c(1,1))

